package com.ss.android.article.base.feature.category.activity;

import android.net.Uri;

import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.feature.app.browser.GetEntryItemHelper;
import com.ss.android.common.util.NetworkUtils;
import com.ss.android.http.legacy.a.NameValueImpl;

import org.json.JSONArray;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import inline.TextDemo;

public final class e extends GetEntryItemHelper {
    public static String c(String arg5) {
        if (!android.support.design.a.isTextEmpty(arg5)) {
            AppData v0 = AppData.getInstance();
            if (!v0.isWebViewCommonQueryEnable) {
                return arg5;
            }

            try {
                String v0_2 = v0.webViewCommonQueryHostList;
                ArrayList<String> v2 = new ArrayList();
                if (!android.support.design.a.isTextEmpty(v0_2)) {
                    JSONArray v3 = new JSONArray(v0_2);
                    int v0_3;
                    for (v0_3 = 0; v0_3 < v3.length(); ++v0_3) {
                        v2.add(v3.optString(v0_3));
                    }
                }

                if (v2.size() <= 0) {
                    return arg5;
                }

                int v0_3;
                String v3_1 = Uri.parse(arg5).getHost();
                if (!android.support.design.a.isTextEmpty(v3_1)) {
                    Iterator<String> v2_1 = v2.iterator();
                    do {
                        if (v2_1.hasNext()) {
                            if (!v3_1.contains(v2_1.next())) {
                                continue;
                            }
                            v0_3 = 1;
                        } else {
                            v0_3 = 0;
                        }
                        break;
                    } while (true);
                } else {
                    v0_3 = 0;
                }

                if (v0_3 == 0) {
                    return arg5;
                }

                if (arg5.contains("common_params_tag")) {
                    return arg5;
                }

                arg5 = arg5.indexOf(63) > 0 ? arg5 + "&" : arg5 + "?";
                ArrayList v0_4 = new ArrayList();
                NetworkUtils.a(v0_4);
                ((List) v0_4).add(new NameValueImpl("common_params_tag", "common_params_tag"));
                arg5 = arg5 + TextDemo.a(((List) v0_4), "UTF-8");
            } catch (Exception v0_1) {
                label_71:
                v0_1.printStackTrace();
            }
        }

        return arg5;
    }

    public final void a(String arg2, boolean arg3) {
        super.a(com.ss.android.article.base.feature.category.activity.e.c(arg2), arg3);
    }

    public final void f() {
        this.y = com.ss.android.article.base.feature.category.activity.e.c(this.y);
        super.f();
    }
}

